]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
search: Allow synchronous searches to be defined with the async API
authorJasper St. Pierre <jstpierre@mecheye.net>
Wed, 2 May 2012 19:26:54 +0000 (15:26 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 7 May 2012 18:21:24 +0000 (15:21 -0300)
To allow this to happen, we need to make sure that we don't overwrite the
previousResults when calling the async method. Note that this is a bug of
some sort, we were already using this synchronous style when a remote
search failed.

https://bugzilla.gnome.org/show_bug.cgi?id=675328

js/ui/search.js

index 1d654fb81e031c7234caa48b087d8c6610dbd1e8..b2348d5d22cd557940c5f26230b0ef03a2385f5f 100644 (file)
@@ -379,14 +379,19 @@ const SearchSystem = new Lang.Class({
             }
         }
 
+        let previousResultsArr = this._previousResults;
+
         let results = [];
+        this._previousTerms = terms;
+        this._previousResults = results;
+
         if (isSubSearch) {
             for (let i = 0; i < this._providers.length; i++) {
-                let [provider, previousResults] = this._previousResults[i];
+                let [provider, previousResults] = previousResultsArr[i];
                 try {
                     if (provider.async) {
-                        provider.getSubsearchResultSetAsync(previousResults, terms);
                         results.push([provider, []]);
+                        provider.getSubsearchResultSetAsync(previousResults, terms);
                     } else {
                         let providerResults = provider.getSubsearchResultSet(previousResults, terms);
                         results.push([provider, providerResults]);
@@ -400,8 +405,8 @@ const SearchSystem = new Lang.Class({
                 let provider = this._providers[i];
                 try {
                     if (provider.async) {
-                        provider.getInitialResultSetAsync(terms);
                         results.push([provider, []]);
+                        provider.getInitialResultSetAsync(terms);
                     } else {
                         let providerResults = provider.getInitialResultSet(terms);
                         results.push([provider, providerResults]);
@@ -412,8 +417,6 @@ const SearchSystem = new Lang.Class({
             }
         }
 
-        this._previousTerms = terms;
-        this._previousResults = results;
         this.emit('search-completed', results);
     },
 });